#include<iostream>
#include<cstring>
using namespace std;
int main(){
	int count = 0,axs = 0;
	double c , m;
	char a1[509],a2[509];
	cin >> m;
	cin >> a1 >> a2;
	for(int i = 0; i < strlen(a1); i++){
		if(a1[i]==a2[i])count++;
		if(count % 2 == 0) axs++;
	}
	c = strlen(a1) % 3 ? 1.0 * axs /(strlen(a1) / 3) :  1.0 * axs /((strlen(a1) / 3)-1);
	if(c > m) cout << "yes" << endl;
	else cout << "no" << endl;
	return 0; 
} 
